package com.cyy.study.nacosconsumer.controller;

import com.cyy.study.nacosconsumer.service.IHelloService;
import com.cyy.study.nacosconsumer.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
public class TestController {

	@Autowired
	private IUserService userService;
	@Autowired
	IHelloService iHelloService;
	
	@RequestMapping(value = "/getUser",method = RequestMethod.GET)
	public String getUser(@RequestParam("username") String username) throws Exception{
		return userService.getUser(username);
	}

	@GetMapping("/getProviderData")
	public List<String> getProviderData(){
		return iHelloService.getProviderData();
	}

	/**
	 *
	 * @return
	 */
	@RequestMapping(value = "/helloService", method = RequestMethod.GET)
	public String getHelloServiceData() {
		return "hello Service";
	}

	@GetMapping("/add")
	public Integer add(Integer a, Integer b){
		return a + b;
	}

	@GetMapping("/a/add")
	public Integer aadd(Integer a, Integer b){
		return a + b;
	}

	@GetMapping("/sub")
	public Integer sub(Integer a, Integer b){
		return a - b;
	}

	@GetMapping("/mul")
	public String mul(Integer a, Integer b){
		System.out.println("进入client-a!");
		return "client-a-" + a * b;
	}

	@GetMapping("/div")
	public Integer div(Integer a, Integer b){
		return a / b;
	}
}
